package com.ev.mes.service.impl;

import com.ev.framework.utils.R;
import com.ev.mes.dao.MaterielPatrolItemDao;
import com.ev.mes.domain.MaterielPatrolItemDO;
import com.ev.mes.service.MaterielPatrolItemService;
import com.ev.mes.vo.MaterielPatrolItemPageParam;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class MaterielPatrolItemServiceImpl implements MaterielPatrolItemService {
    @Autowired
    private MaterielPatrolItemDao materielPatrolItemDao;

    @Override
    public MaterielPatrolItemDO get(Long id) {
        return materielPatrolItemDao.get(id);
    }

    @Override
    public List<MaterielPatrolItemDO> list(Map<String, Object> map) {
        return materielPatrolItemDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return materielPatrolItemDao.count(map);
    }

    @Override
    public int save(MaterielPatrolItemDO materielPatrolItem) {
        return materielPatrolItemDao.save(materielPatrolItem);
    }

    @Override
    public int update(MaterielPatrolItemDO materielPatrolItem) {
        return materielPatrolItemDao.update(materielPatrolItem);
    }

    @Override
    public int updateAll(MaterielPatrolItemDO materielPatrolItem) {
        return materielPatrolItemDao.updateAll(materielPatrolItem);
    }

    @Override
    public int remove(Long id) {
        return materielPatrolItemDao.remove(id);
    }

    @Override
    public int batchRemove(Long[] ids) {
        return materielPatrolItemDao.batchRemove(ids);
    }

    @Override
    public R saveAndVerify(MaterielPatrolItemDO saveParam) {
        if (saveParam.getId() != null) {
            return materielPatrolItemDao.update(saveParam) > 0 ? R.ok() : R.error();
        }
        return materielPatrolItemDao.save(saveParam) > 0 ? R.ok() : R.error();
    }

    @Override
    public Map<String, Object> getById(Long id) {
        MaterielPatrolItemDO materielPatrolItem = materielPatrolItemDao.get(id);
        Map<String, Object> result = Maps.newHashMap();
        if (materielPatrolItem !=null){
            result.put("data",materielPatrolItem);
            return result;
        }
        return result;
    }

    @Override
    public Map<String, Object> pageList(MaterielPatrolItemPageParam pageParam) {
//        Map<String, Object> result = Maps.newHashMap();
//        List<Map<String, Object>> data = materielPatrolItemDao.pageList(pageParam);
//        if (data.size() > 0) {
////            int total = materielPatrolItemDao.pageCount(pageParam);
////            result.put("data", new DsResultResponse(pageParam.getPageno(), pageParam.getPagesize(), total, data));
//        }
        return null;
    }

}
